package ooday04;

/**
 * 说明:
 *
 * @author:SuZhongHe
 * @date:2023/2/22
 **/
public class Text {
    public static void main(String[] args) {
        Animal[] animal= new Animal [9];
        animal[0]=new Dog("小黄",2,"白");
        animal[1]=new Dog("小黑",3,"绿");
        animal[2]=new Dog("小白",1,"黑");
        animal[3]=new Fish("中黄",1,"黑");
        animal[4]=new Chick("小绿",2,"白");
        animal[5]=new Chick("小白",3,"绿");
        animal[6]=new Chick("小花",1,"黑");
        animal[7]=new Fish("小金",2,"白");
        animal[8]=new Fish("大绿",3,"绿");
        System.out.println(animal[0].name);
       animal[1].age=4;
        for (int i = 0; i < animal.length; i++) {
            System.out.println(animal[i].name);
            animal[i].eat();
            animal[i].drink();
            if (animal[i]instanceof Dog){
                Dog dog=(Dog) animal[i];
                dog.lookHome();
            }
            if(animal[i]instanceof Chick){
                Chick chick=(Chick) animal[i];
                chick.layEggs();
            }
            if (animal[i]instanceof Fish){
                Fish fish=(Fish) animal[i];
                fish.swim();
            }
        }



        /*

        Master master = new Master();
        master.feed(animal[0]);
        master.feed(animal[3]);
        master.feed(animal[5]);

         */


    }
}
